package com.soft.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.soft.entity.Banji;
import com.soft.entity.Dept;
import com.soft.mapper.BanjiMapper;

@Service
public class BanjiService {
    @Autowired
    private BanjiMapper banjiMapper;
    
    public List<Banji> queryAll() {
        List<Banji> banjiList = banjiMapper.selectList(null);
        return banjiList;
    }
    public List<Banji>queryByLoc(String BanjiTeacherName)
    {
    	QueryWrapper<Banji> qw = new QueryWrapper<>();
    	qw.eq("banji_teacher",BanjiTeacherName );
    	List<Banji> banjiList = banjiMapper.selectList(qw);
    	return banjiList;
    }
    public int insertOne(String banjiRenshu,String banjiTeacher)
    {
    	Banji banji = new Banji();
    	banji.setBanjiRenshu(banjiRenshu);
    	banji.setBanjiTeacher(banjiTeacher);
    	int num = banjiMapper.insert(banji);
    	return num;
    }
    public int deleteById(String id) {
    	Banji banji = new Banji();
    	banji.setBanjiBanjihao(id);
    	int num = banjiMapper.deleteById(banji);
    	return num;
    }
    public int deleteByName(String Renshu)
	{
		QueryWrapper<Banji> qw = new QueryWrapper();
		qw.eq("banji_renshu", Renshu);
		return banjiMapper.delete(qw);
	}
    public int updateByDno(String banjihao)
	{
		UpdateWrapper<Banji> uw = new UpdateWrapper<>();
		uw.gt("banji_banjihao", banjihao);
		Banji banji = new Banji();
		banji.setBanjiTeacher("李华");
		return banjiMapper.update(banji,uw);
	}
}